using System;
using System.Collections.Generic;
using System.Text;

using Jayrock.Json;
using Jayrock.Json.Conversion;

namespace Client
{
    public class OneWayMessage
    {
        private Object m_body;
        private OneWayMessageHeader m_header;

        public OneWayMessage() 
        {
            m_header = new OneWayMessageHeader();
        }

        public OneWayMessage(Uri to, String action, Object body)
        {
            m_header = new OneWayMessageHeader(to, Guid.NewGuid(), action);
            m_body = body;
        }

        /// <summary>
        /// message header.
        /// </summary>
        public OneWayMessageHeader Header
        {
            get { return m_header; }
            set { m_header = value; }
        }

        public Object Body
        {
            get { return m_body; }
            set { m_body = value; }
        }

        /// <summary>
        /// get typed body
        /// </summary>
        /// <typeparam name="TBody"></typeparam>
        /// <returns></returns>
        public TBody GetBody<TBody>()
        {
            return (TBody)m_body;
        }
    }
}
